import { createRouter, createWebHistory } from 'vue-router'
const routerHistory = createWebHistory() // history router

const router = createRouter({
    history: routerHistory,
    routes: [
      {
        path: '/',
        component: () => import('@/views/home/index.vue'),
      },
      {
        path: '/user',
        component: () => import('@/layouts/basicLayout.vue'),
        redirect: '/user/base-info',
        children: [
          {
            path: 'base-info',
            name:'baseInfo',
            component: () => import('@/views/userCenter/userInfo.vue')
          },
          {
            path: 'book-manage',
            name:'bookManage',
            component: () => import('@/views/userCenter/bookManage.vue')
          },
          {
            path: 'data-manage',
            name: 'dataManage',
            component: () => import('@/views/userCenter/dataManage.vue')
          },
          {
            path: 'book-manage/information',
            component: () => import('@/views/userCenter/information.vue')
          },
          {
            path: 'book-manage/manage',
            component: () => import('@/layouts/subRouterView.vue'),
            children: [
              {
                path: '',
                name: 'manage',
                component: () => import('@/views/userCenter/chapterManage.vue')
              },
              {
                path: 'draft',
                name: 'draft',
                component: () => import('@/views/userCenter/draftChapterManage.vue')
              },
              {
                path: 'detail',
                name: 'detail',
                component: () => import('@/views/userCenter/bookInfo.vue')
              }
            ]
          },
          {
            path: 'book-shelf',
            name:'bookShelf',
            component: () => import('@/views/userCenter/bookShelf.vue')
          },
          {
            path: 'approval-center',
            name: 'approvalCenter',
            redirect: '/user/approval-center/author',
            component: () => import('@/layouts/approvalCenter.vue'),
            children: [
              {
                path: 'author',
                name: 'author',
                component: () => import('@/views/admin/checkAuthor.vue')
              },
              {
                path: 'book',
                name: 'book',
                component: () => import('@/views/admin/checkBook.vue')
              },  
              {
                path: 'book-edit',
                name: 'bookEdit',
                component: () => import('@/views/admin/checkBookEdit.vue')
              }, 
              {
                path: 'chapter',
                name: 'chapter',
                component: () => import('@/views/admin/checkChapter.vue')
              }, 
              {
                path: 'chapter-edit',
                name: 'chapterEdit',
                component: () => import('@/views/admin/checkChapterEdit.vue')
              }, 
              {
                path: 'sign',
                name: 'sign',
                component: () => import('@/views/admin/checkSign.vue')
              },
              {
                path: 'data-center',
                name: 'dataCenter',
                component: () => import('@/views/admin/checkDAata.vue')
              }  
            ]
          }
        ]
      },
      {
        path: '/book',
        component: () => import('@/layouts/bookLayout.vue'),
        children: [
          {
            path: 'chapter/upload',
            name: 'upload',
            component: () => import('@/views/userCenter/bookUpload.vue')
          }
        ]
      },
      {
        path: '/shuku/:id',
        component: () => import('@/layouts/detailLayout.vue')
      },
      {
        path: '/shuku/:id/:cid',
        component: () => import('@/views/book/bookDetail.vue')
      }
    ]
})

export default router